package com.demo.test.file;

import org.junit.Test;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;

/**
 * @author gy
 * @date 2023/4/12
 */
public class FileExist {
    @Test
    public void m1(){
        String path = "D:\\typx_student\\typx_webtrn\\target\\war-webapp\\incoming\\report\\typxNew\\b07df8488a0141c6b492701247575ad7\\82808185876f68fb01877034ecf10003\\4028ab9d866770cc01866c9674b30003\\1681264135\\测试无法查看附件 - 2.xlsx";
        File file = new File(path);
        System.out.println(file.exists());
    }

    @Test
    public void m2(){
        String path = "D:\\typx_student\\typx_webtrn\\target\\war-webapp\\incoming\\report\\typxNew\\b07df8488a0141c6b492701247575ad7\\82808185876f68fb01877034ecf10003\\4028ab9d866770cc01866c9674b30003\\1681264135";
        File dir = new File(path);
        System.out.println(dir.exists());
    }

    /**
     * 从本地文件中查出来的
     */
    @Test
    public void m3(){
        String path = "D:\\typx_student\\typx_webtrn\\target\\war-webapp\\incoming\\report\\typxNew\\b07df8488a0141c6b492701247575ad7\\82808185876f68fb01877034ecf10003/4028ab9d866770cc01866c9674b30003/1681264135/测试无法查看附件 - 2.xlsx";
        File dir = new File(path);
        System.out.println(dir.exists());
    }

    /**
     * 前端传过来的 65293
     */
    @Test
    public void m4(){
        String path = "D:\\typx_student\\typx_webtrn\\target\\war-webapp\\incoming\\report\\typxnew\\b07df8488a0141c6b492701247575ad7\\82808185876f68fb01877034ecf10003\\4028ab9d866770cc01866c9674b30003\\1681264135\\测试无法查看附件 － 2.xlsx";
        File dir = new File(path);
        System.out.println(dir.exists());
    }

    /**
     * 数据库存储的 65293
     */
    @Test
    public void m5(){
        String path = "incoming/report/typxnew/b07df8488a0141c6b492701247575ad7/82808185876f68fb01877034ecf10003/4028ab9d866770cc01866c9674b30003/1681264135/测试无法查看附件 － 2.xlsx";
        File dir = new File(path);
        System.out.println(dir.exists());
    }


    /**
     * 对字符文件编解码
     */
    @Test
    public void m6() throws UnsupportedEncodingException {
        String path = "incoming/report/typxnew/b07df8488a0141c6b492701247575ad7/82808185876f68fb01877034ecf10003/4028ab9d866770cc01866c9674b30003/1681264135/测试无法查看附件 － 2.xlsx";
        byte[] bytes = path.getBytes();
//        String path2 = new String(bytes,"gbk");
//        String path2 = new String(bytes,"utf-8");
//        String path2 = new String(bytes,"gb2312");
        String path2 = new String(bytes,"utf8mb4");
        System.out.println(path2);
        File dir = new File(path2);
        System.out.println(dir.exists());
    }

    /**
     * 对字符文件编解码
     */
    @Test
    public void m7() throws UnsupportedEncodingException {
        String path = "incoming/report/typxnew/b07df8488a0141c6b492701247575ad7/82808185876f68fb01877034ecf10003/4028ab9d866770cc01866c9674b30003/1681264135/测试无法查看附件 － 2.xlsx";
        byte[] bytes = path.getBytes();
//        String path2 = new String(bytes,"gbk");
//        String path2 = new String(bytes,"utf-8");
//        String path2 = new String(bytes,"gb2312");
        String path2 = new String(bytes,"utf8");
        System.out.println(path2);
        File dir = new File(path2);
        System.out.println(dir.exists());
    }

    @Test
    public void m(){
        String timestamp = String.valueOf(System.currentTimeMillis());
        System.out.println(timestamp);
    }
}
